#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>

int main()
{
    
    printf("父进程开始执行->pid=%d\n", getpid());
    int ret = fork();
    if(ret == -1)
    {
        perror("fork fail");
        exit(1);
    }
    else if(ret == 0)
    {
        int count = 10;
        while(count--)
        {
            sleep(1);
            printf("子进程开始执行->%d\n", count);
        }
    }
    else
    {
        while(1)
        {
            sleep(1);
        }
    }
    


   // printf("父进程开始执行->pid=%d\n", getpid());
   // while(1)
   // {
   //     sleep(1);
   //     printf("hello mihayou\n");
   // }
    return 0;
}
